import App from './App'
import Request from './uilt/request.js'
// import {upload
// } from './util/upload.js'
import wxSdk from './uilt/wxSdk.js'
// import wxSdk from './uilt/wxSdk.js'
import {
	upload
} from './uilt/upload.js'

Vue.prototype.$http = Request.http
// Vue.prototype.$upload = upload
Vue.prototype.$wxSdk = wxSdk
Vue.prototype.$upload = upload

// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
    ...App
})
app.$mount()

//替换富文本中的图片样式
Vue.prototype.$replace_Rich_text = function(html) {
 let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
  match = match.replace(/style\s*?=\s*?([‘"])[\s\S]*?\1/, '').replace(/\style='[^']+'/gi, '');
  match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
  match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
  return match;
 });
 newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
  match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
   'max-width:100%;');
  return match;
 });
 newContent = newContent.replace(/<br[^>]*\/>/gi, '');
 newContent = newContent.replace(/\<img/gi,
  '<img style="max-width:100%;height:auto;display:block;margin:0 auto;"');
 return newContent;
}
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif